package com.charger.kanban.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.charger.common.annotation.Log;
import com.charger.common.core.controller.BaseController;
import com.charger.common.core.domain.AjaxResult;
import com.charger.common.enums.BusinessType;
import com.charger.kanban.domain.Kanban;
import com.charger.kanban.service.IKanbanService;
import com.charger.common.utils.poi.ExcelUtil;
import com.charger.common.core.page.TableDataInfo;

/**
 * 监控看板Controller
 * 
 * @author charger1
 * @date 2024-11-27
 */
@RestController
@RequestMapping("/realtimemonitor/kanban")
public class KanbanController extends BaseController
{
    @Autowired
    private IKanbanService kanbanService;

    /**
     * 查询监控看板列表
     */
    @PreAuthorize("@ss.hasPermi('realtimemonitor:kanban:list')")
    @GetMapping("/list")
    public TableDataInfo list(Kanban kanban)
    {
        startPage();
        List<Kanban> list = kanbanService.selectKanbanList(kanban);
        return getDataTable(list);
    }

    /**
     * 导出监控看板列表
     */
    @PreAuthorize("@ss.hasPermi('realtimemonitor:kanban:export')")
    @Log(title = "监控看板", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Kanban kanban)
    {
        List<Kanban> list = kanbanService.selectKanbanList(kanban);
        ExcelUtil<Kanban> util = new ExcelUtil<Kanban>(Kanban.class);
        util.exportExcel(response, list, "监控看板数据");
    }

    /**
     * 获取监控看板详细信息
     */
    @PreAuthorize("@ss.hasPermi('realtimemonitor:kanban:query')")
    @GetMapping(value = "/{chargerId}")
    public AjaxResult getInfo(@PathVariable("chargerId") Long chargerId)
    {
        return success(kanbanService.selectKanbanByChargerId(chargerId));
    }

    /**
     * 新增监控看板
     */
    @PreAuthorize("@ss.hasPermi('realtimemonitor:kanban:add')")
    @Log(title = "监控看板", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Kanban kanban)
    {
        return toAjax(kanbanService.insertKanban(kanban));
    }

    /**
     * 修改监控看板
     */
    @PreAuthorize("@ss.hasPermi('realtimemonitor:kanban:edit')")
    @Log(title = "监控看板", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Kanban kanban)
    {
        return toAjax(kanbanService.updateKanban(kanban));
    }

    /**
     * 删除监控看板
     */
    @PreAuthorize("@ss.hasPermi('realtimemonitor:kanban:remove')")
    @Log(title = "监控看板", businessType = BusinessType.DELETE)
	@DeleteMapping("/{chargerIds}")
    public AjaxResult remove(@PathVariable Long[] chargerIds)
    {
        return toAjax(kanbanService.deleteKanbanByChargerIds(chargerIds));
    }
}
